<?php

namespace App\Listeners\Plane\PlaneOrder\Refund;

use App\Events\Plane\PlaneOrder\Refund\PlaneOrderTicketReturnFailedEvent;
use Exception;

class PlaneOrderTicketReturnFailedListener
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param object $event
     * @return void
     */
    public function handle(PlaneOrderTicketReturnFailedEvent $event)
    {
        $return_info = $event->return;
        $notify      = $event->notify;
        $order_info  = $return_info->getOrderInfo();

        switch ($order_info->order_service) {
            case 'book51':
                $return_info->ticket_return_failed([
                    'failed_reason' => $notify->getProviderRemark(),
                    'return_state'  => 2,
                ]);
                break;
            default:
                throw new Exception("order service error ");
        }
    }
}
